#include <stdio.h>
#include <string.h>

typedef int b;

b cube[22][22][22] = {};
int w, x, h;

void op(int x1, int y1, int z1, int x2, int y2, int z2)
{
    for (int i = x1 - 1; i < x2; ++i)
        for (int j = y1 - 1; j < y2; ++j)
            for (int k = z1 - 1; k < z2; ++k)
            {
                cube[i][j][k] = 0;
            }
}

int main()
{
    scanf("%d%d%d", &w, &x, &h);
    for (int i = 0; i < w; ++i)
        for (int j = 0; j < x; ++j)
            for (int k = 0; k < h; ++k)
            {
                cube[i][j][k] = 1;
            }
    int op_cnt = 0;
    scanf("%d", &op_cnt);
    int x1, y1, z1, x2, y2, z2;
    for (int i = 0; i < op_cnt; ++i)
    {
        scanf("%d%d%d%d%d%d", &x1, &y1, &z1, &x2, &y2, &z2);
        op(x1, y1, z1, x2, y2, z2);
    }
    int res = 0;
    for (int i = 0; i < w; ++i)
        for (int j = 0; j < x; ++j)
            for (int k = 0; k < h; ++k)
            {
                res += cube[i][j][k];
            }
    printf("%d", res);
    return 0;
}